﻿namespace blackhouse.mojoPortalExtend
{
    using blackhouse.JavaScript.JQuery;
    using blackhouse.Web.FasterFiles;
    using System;
    using System.Runtime.CompilerServices;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public class SelectFileTextBox : TextBox
    {
        public SelectFileTextBox()
        {
            this.ButtonText = "wybierz plik";
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            new JQueryLibraries().IncludeFileBasedOnJQuery("blackhouse.Web.mojoPortal.SelectFileTextBox.js,blackhouse.Web.mojoPortal");
            new FasterFilesProvider().AddCssFile(typeof(SelectFileTextBox), "blackhouse.Web.mojoPortal.SelectFileTextBox.css");
        }

        protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "openFileDialog");
            writer.RenderBeginTag(HtmlTextWriterTag.A);
            writer.Write(this.ButtonText);
            writer.RenderEndTag();
        }

        public string ButtonText { get; set; }
    }
}

